Skip to content

Support jdeploy.args in package.json for JVM/program arguments#467

Merged
shannah merged 2 commits into
masterfrom
claude/jdeploy-add-opens-support-alfa91
Jul 8, 2026
Merged

Support jdeploy.args in package.json for JVM/program arguments#467
shannah merged 2 commits into
masterfrom
claude/jdeploy-add-opens-support-alfa91

Conversation

@shannah

@shannah shannah commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Adds support for declaring JVM and program arguments in package.json's jdeploy.args array, which are injected into the generated jdeploy.js launcher. This mirrors the argument processing behavior of the client4j launcher, including platform-conditional syntax and proper splitting of multi-token JVM options.

Key Changes

  • jdeploy.js launcher enhancements:

    • Added packageArgs variable injected at publish time as a JSON array literal
    • Implemented processPackageArg() function to resolve platform-conditional prefixes (-[conditions], -D[conditions], -X[conditions])
    • Implemented appendPackageArgs() function to categorize arguments into JVM args (before -jar) and program args (after jar)
    • Properly splits multi-token JVM options like --add-opens java.desktop/com.apple.eawt=ALL-UNNAMED into separate tokens
    • Supports pipe-OR conditions (e.g., -[mac|linux]) for multi-platform targeting
  • PackageService.java:

    • Added toJavaArgsJson() method to serialize the jdeploy.args list from package.json into a JSON array literal
    • Modified processJdeployTemplate() to inject the serialized args as {{JAVA_ARGS}} placeholder
  • Comprehensive test coverage:

    • Added package-args.test.js regression test that extracts and tests the real processPackageArg and appendPackageArgs functions from jdeploy.js
    • Tests platform-conditional prefixes, multi-token splitting, OR conditions, and edge cases
    • Mocks process.platform to exercise all platform branches on any host
    • Updated test.sh to run the platform-independent package-args test before platform-specific tests

Implementation Details

The argument processing mirrors the client4j launcher's behavior:

  • Platform conditions are evaluated at runtime on the target machine (not at publish time)
  • Arguments starting with -D or -X are treated as JVM arguments
  • Arguments starting with -- (module/access options) are split on spaces to separate flag from value
  • The -p short form of --module-path is split into two tokens
  • Non-dash arguments are treated as program arguments
  • Package args are prepended before user-supplied CLI arguments

https://claude.ai/code/session_013aT4ipGJM1Wv1D5bhrPBj6

claude added 2 commits July 8, 2026 01:47
…deploy.js launcher

The npm launcher (jdeploy.js) previously ignored the jdeploy.args array in
package.json, so publishers had to hand-edit the generated launcher to add JVM
flags like --add-opens after deploying. It now processes jdeploy.args at
runtime, mirroring the client4j (Go) launcher: platform-conditional prefixes
(-[mac], -D[win], -X[linux], pipe-OR groups) resolve on the running machine,
and --flag value options such as --add-opens are split into the two tokens the
JVM expects. Args are injected at publish time via a {{JAVA_ARGS}} placeholder.

Adds a platform-mocked unit test for the arg processing.
testJDeployScript performs its own placeholder substitution independent of
PackageService, and did not replace the new {{JAVA_ARGS}} token, leaving an
invalid `var packageArgs = {{JAVA_ARGS}};` in the generated launcher (Node
SyntaxError). Replace it with an empty array to match a package.json with no
jdeploy.args.
@shannah
shannah merged commit c103669 into master Jul 8, 2026
19 checks passed
@shannah
shannah deleted the claude/jdeploy-add-opens-support-alfa91 branch July 8, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants